#install package "survival"
#load packages
library(survival)

#read/name the data table
acorns<-read.csv(file.choose())
head(acorns)
attach(acorns)

#fit the hazard function to the data
mod.acorns<-coxph(formula = Surv(days, removal)~
                    cluster(plot)+habitat+weight,acorns)

#get model summary
summary(mod.acorns)

#plot a model of the survival function
plot(survfit(mod.acorns))

# test the assumption for proportional hazards
# look for nonlinearity in Beta for each covariate over time
cox.zph(mod.acorns)
